// This file embeds resources like Dockerfiles to be used in fyne-cross
// TODO: move to go:embed once the go min version required by fyne-cross will be 1.16
package main

import (
	"fmt"
	"io/ioutil"
	"os"
	"text/template"
)

func main() {
	b, err := ioutil.ReadFile("docker/darwin/Dockerfile")
	if err != nil {
		fmt.Printf("could not read darwin Dockerfile, please run from the project root: %s", err)
		os.Exit(1)
	}

	f, err := os.Create("internal/resource/darwin_dockerfile.go")
	if err != nil {
		fmt.Printf("could not write embedded darwin Dockerfile, please run from the project root: %s", err)
		os.Exit(1)
	}
	t := template.Must(template.New("dockerfile").Parse(tpl))
	t.Execute(f, fmt.Sprintf("`%s`", b))
}

var tpl = `// auto-generated by cmd/internal/main.go DO NOT EDIT.

package resource

const DockerfileDarwin = {{.}}
`
